<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>随机选颜色</title>
</head>
<body>
    <div>
        <h1>本次选择的颜色:<span id="color"></span></h1>
        <button onclick="show()">选择颜色</button>
    </div>
    <script>
        function show(){
            let arr = ['红','蓝','绿','紫','青','黄','白']
            let num = Math.floor(Math.random() * arr.length);
            console.log(num)
            document.getElementById("color").innerText = arr[num]
        }

    </script>
</body>
</html>